<?php

class Default_Model_UserProfile
{

    public $groups;
    public $groupHash;
    public $username;
    public $bookmarks;
    function __construct()
    {
        $this->GetGroups();
        $this->username = 'uriah280';
    }

    function GetGroups()
    {
        $DATA_URI  = DATA_PATH . "/subdata.txt";
        $groupList = file_get_contents($DATA_URI);
        parse_str($groupList);
        sort($my);
        $this->groups = $my; 
        foreach ($my as $name) $this->groupHash[$name] = $name;
    }

    function Subscribe($name)
    {
        $DATA_URI  = DATA_PATH . "/subdata.txt";
        $groupList = file_get_contents($DATA_URI);
        $tmp=array();
        $out=array();
        parse_str($groupList);
        for ($x=0;$x<sizeof($my);$x++) {
            if ($my[$x]==$name) $found=true;
            else $tmp[]=$my[$x];
        }
        if (!$found) $tmp[] = $name;
        for ($x=0;$x<sizeof($tmp);$x++) {
            $out[]='my[]='.$tmp[$x];
        }
        file_put_contents($DATA_URI,implode('&', $out));
    }

    function IsSubscribed($name)
    {
        return $this->groupHash[$name];
    }

    function GetBookmarks($param="")
    {
        $app = new Default_Model_BookmarkManager($param);
        $this->bookmarks = $app->Bookmarks; 
    }
}

